<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml" xmlns:shiro="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<head th:include="include :: header">

</head>
<style>
	.main{
        margin: 16px 0 0 0;
        width:100%;
        height:auto;
    }
    .name{
        font-size: 14px;
        font-weight: bold;
        margin-top: 16px;
        height: 48px;
        line-height: 48px;
        padding-left: 16px;
        color: #3F4F60;
        border-radius: 4px;
        background: #fff;
    }
    .echart-box{
        background: #fff;
        padding: 16px;
        margin-bottom: 16px;
        border-radius: 4px;
    }
    .echart-box{
        clear: both;
        overflow: hidden;
    }
    .echart-box .item{
        float: left;
        width: 31%;
        margin-right: 2.333%;
        border-radius: 4px;
    }
    .echart-box .tit{
        font-size: 18px;
        margin-bottom: 24px;
        color: #06172A;
        position: relative;
        font-weight: bold;
        padding-left: 12px;
    }
    .echart-box .tit:after{
        content: '';
        width: 4px;
        height: 18px;
        background: var(--buttonborder);
        position: absolute;
        left: 0;
        top: 50%;
        margin-top: -8px;
    }
    .echart-box .text{
        color: #5a5f72;
        margin: 8px 0;
        position: relative;
        padding-left: 10px;
     }
    .echart-box .text:after{
        content: '';
        width: 4px;
        height: 14px;
        background: #2C82EB;
        position: absolute;
        left: 0;
        top: 50%;
        margin-top: -7px;
    }
    .echart-box .num{
        font-size: 30px;
        font-size: bold;
        padding-bottom: 8px;
        border-bottom: 1px solid #ccc;
    }
    .echart-box-two{
        background: #fff;
        padding: 18px;
    }
    .echart-box-two .item{
        background: #fff;
    }
    #totalProportion,#scoreEcharts{
    border: 1px solid var(--buttonborder);
    }
    #mydiv1{
        flex-direction: var(--rowAndColumn);
    }
</style>
<body class="gray-bg" style="padding-right: 10px;">
<div class="wrapper wrapper-content ">
    <p class="name">全国职业院校技能大赛中等职业教育 -- 婴幼儿照护赛项</p>
    <div id="main" class="main">
        <div id="mydiv1" class="echart-box-two echart-box" style="display: flex;">
            <div class="item" style="flex:1;margin-right: 1%; width: 100%;">
                <p class="tit">总得分占比--折线图</p>
                <div id="totalProportion" style="height:456px;border-radius: 4px"></div>
            </div>
            <div class="item"  style="flex:1;margin-right: 0;    width: 100%;">
                <p class="tit">总得分占比--饼状图</p>
                <div id="scoreEcharts" style="height:456px;border-radius: 4px"></div>
            </div>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script type="text/javascript" >
    const myColor=window.getComputedStyle(document.body).getPropertyValue('--buttonborder')
    var myChart1=null,myChart2=null;
    $(function() {

        $.ajax({
            url: "/recordPoints/moduleScoreProportion",
            type: "get",
            data: {
            },
            success: function (res) {
                if(res==null){
                    layer.msg("未查询到数据！");
                }
                else {

                    let x=['0-20分', '21-40分','41-60分', '61-80分','81-90分','91-100分']
                    let y=[res.data.takeScore20,
                           res.data.takeScore40,
                           res.data.takeScore60,
                           res.data.takeScore80,
                           res.data.takeScore90,
                           res.data.takeScore100]
                    let py=[]
                    for (let i = 0; i < x.length; i++) {
                        py.push({
                            value: y[i],
                            name: x[i]
                        })
                    }
                    console.log('py',py)
                    totalProportion(x,y)
                    sexEcharts(py)
                }
            }
        });

     window.onresize=()=>{
         myChart1?.resize()
         myChart2?.resize()
     }

    })
    function sexEcharts(data) {
        var dom = document.getElementById("scoreEcharts");
        myChart2 = echarts.init(dom);
        var option;
        option = {
            color: [myColor,'#F69C36'],
            tooltip: {
                trigger: 'item',
                formatter: "{b}: {c} ({d}%)",
            },
            grid: {
                top: '1%', // 控制饼图距离容器顶部的距离
                left: 'center' // 控制饼图水平居中显示
            },
            legend: {//图例
                x : '86%',
                y : 'center',
                itemHeight: 12,                      //修改icon图形大小
                icon: 'circle',
            },
            series: [
                {
                    name: '',
                    type: 'pie',
                    radius: ['40%', '60%'],
                    data: data,
                    labelLine:{
                        normal:{
                            length:15,
                        },
                    },
                    label: {
                        normal: {
                            formatter: function(params){
                                return params.name+"\n\n"+params.percent+"%";
                            },
                            textStyle: {            // 提示文字的样式
                                color: '#3F4F60',
                                fontSize: 14
                            }
                        }
                    }
                }
            ]
        };
        if (option && typeof option === 'object') {
            myChart2.setOption(option);
        }

    }
    function totalProportion(x,y){
        var dom = document.getElementById("totalProportion");
        myChart1 = echarts.init(dom);
        var option;
        option = {
            tooltip: {
                trigger: 'axis',
                formatter: function (params) {
                    let mytooltip=`${option.xAxis.data[params[0].dataIndex]}：`
                    for (let i = 0; i < params.length; i++) {
                        let item=params[i]
                        mytooltip+=`${item.value}<br/>`
                    }
                    return mytooltip
                },
            },
            legend: {//图例
                show:true,
                x : 'center',
                y : 'bottom',
                itemHeight: 12,                      //修改icon图形大小
                icon: 'circle',
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '10%',
                containLabel: true
            },
            xAxis: {
                type: 'category',
                axisTick: {
                    alignWithLabel: true
                },
                axisLabel: {
                    show: true, // 是否显示刻度标签，默认显示
                    margin: 16, // 刻度标签与轴线之间的距离
                    color:'#3F4F60',
                },
                data: x
            },
            yAxis: {
                type: 'value',
            },
            series: [
                {
                    data: y,
                    type: 'line',
                    color:myColor,
                    smooth: true,
                    label: {
                        show: true,
                        position: 'top',
                        color:'#3F4F60'
                    },
                }
            ]
        };
        if (option && typeof option === 'object') {
            myChart1.setOption(option);
        }
    }

</script>
</body>
</html>